---@class BuffEffect31 : BaseBuffEffect
BuffEffect31 = ClientFight.CreateClass("BuffEffect31", ClientFight.BaseBuffEffect)
local t = BuffEffect31
---@param fight Fight
---@param buff FighterBuff
function t:action(fight, buff, ...)
    local parameters = {...}
    local target = buff.target;
    local remove = {};

    local overlay = buff.buffBean.f_BuffEffectValue[2];
    if (overlay == 0) then
        overlay = 2147483647;
    end
    local buffsList = target.buffs;
    for k, _buff in pairs(buffsList) do
        if (overlay <= 0) then
            break ;
        end
        if (buff.buffBean.f_BuffEffectValue[1] == _buff.buffBean.f_BuffType) then
            if (_buff.overlay < overlay) then
                table.insert(remove, _buff);
                overlay = overlay - _buff.overlay;
            else
                _buff.overlay = buff.overlay - overlay;
                -- 重置效果
                BuffEffectManager.addBuffEffect(fight, _buff);
                local logOverlay = overlay;
                SkillRoleMgr.savePathFile("[" .. fight.frame .. "][EFFECT]Fighter " .. buff.target.fighterId .. " Buff:"
                        .. buff.modelId .. " 移除Buff(" .. _buff.modelId .. ")" .. logOverlay);
                overlay = 0;
            end
        end
    end

    if (table.getn(remove) ~= 0) then
        for k, fighterBuff in pairs(remove) do
            BuffManager.removeFighterBuff(fight, target, fighterBuff, true, buff.addParameters);
            SkillRoleMgr.savePathFile("[" .. fight.frame .. "][EFFECT]Fighter " .. buff.target.fighterId .. " Buff:" .. buff.modelId .. " 移除Buff(" .. fighterBuff.modelId .. ")");
        end
    end
    return ClientFight.BaseBuffEffect.action(self, fight, buff, parameters);
end

t.New()